package com.dh.example.netty.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;

/**
 * @author yolo
 * @date 2024/3/15 10:04
 * @mail yolo_215@163.com
 */
@Getter
@AllArgsConstructor
public enum WsReqTypeEnum {

    /**
     * 1 请求登录二维码
     * 2 心跳
     */
    LOGIN_URL("LOGIN_URL", "请求登录二维码"),
    PING("PING", "心跳"),
    ;
    private static final Map<String, WsReqTypeEnum> CACHE;

    static {
        CACHE = Arrays.stream(WsReqTypeEnum.values()).collect(Collectors.toMap(WsReqTypeEnum::getType, Function.identity()));
    }

    /**
     * 类型
     */
    private final String type;
    /**
     * desc
     */
    private final String desc;

    public static WsReqTypeEnum of(String type) {
        return CACHE.get(type);
    }
}
